package com.ph.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ph.feign.GroupFeign;
import com.ph.mapper.KeepPlanMapper;
import com.ph.pojo.KeepPlan;
import com.ph.pojo.User;
import com.ph.service.KeepPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class KeepPlanServiceImpl extends ServiceImpl<KeepPlanMapper, KeepPlan> implements KeepPlanService {
    @Autowired
    private GroupFeign groupFeign;

    @Override
    public List<KeepPlan> findAll() {
        List<KeepPlan> keepPlans = baseMapper.findAll();
        for (KeepPlan keepPlan : keepPlans){
            User user = groupFeign.keepFindById(keepPlan.getCreateId()).getData();
            if (user != null){
                keepPlan.setCreateName(user.getName());
            }
//            else keepPlan.setCreateName("未知");
        }
        return keepPlans;
    }
}
